package com.hualude.roadsign.repository;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.PacketInfoDto;
import com.hualude.roadsign.model.PacketInfoEntity;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by xu_jiaHui on 2017/10/30.
 */
public interface PacketInfoRepository extends CrudRepository<PacketInfoEntity, Long> {

    /**
     * @Descriptin: 通过deviceId获取日志信息
     * @author xu_jiaHui
     * @date 2017/10/30 18:57
     */
    public List<PacketInfoDto> getDeviceRecord4DT(DTRequestDto dtRequestDto, String deviceId, String type) throws Exception;

    @Query(value = "select count(*) from PacketInfoEntity where createTime like concat(:search,'%') and deviceId=:deviceId and infoType like concat(:infoType,'%')")
    public Integer getDeviceRecordCount4DT(@Param("search") String search, @Param("deviceId") String deviceId, @Param("infoType") String infoType) throws Exception;
}
